<template>
  <div class="constentmain">
    <list-table-new v-bind="tableSetting" ref="klTable"> </list-table-new>
  </div>
</template>
<script>
import { queryPatrolStandardList } from "@/api/standardManagement/patrolStandard.js";
export default {
  props: {
    searchData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      checked: false,
      tableSetting: {
        radioShow: true,
        selectionShow: false,
        showFilterBtn: false,
        showCustomBtn: false,
        searchObj: {
          searchMethod: (params, sortStr) => {
            this.getTableData(params, sortStr);
          },
          queryData: {
            page: 1,
            pageSize: 15,
            status: 1,
            publicStatus: 1
          },
          searchArr: [
            {
              type: "input",
              label: "编号",
              model: "code",
              placeholder: "请输入",
            },
            {
              type: "input",
              label: "标题",
              model: "name",
            },
            {
              type: "deviceClassify",
              label: "设备分类",
              model: "typeWrapName",
              idsStr: "typeWrapId",
              disabled:true,
            },
            {
              type: "organization",
              label: "创建单位",
              model: "deptName",
              idsStr: "deptId",
            },
          ],
        },
        //过滤器的值
        filterFormData: {},
        //过滤器的默认值
        defaultFilterData: {},
        userCustomData: [],
        actionList: [],
        column: [
          {
            label: "编号",
            prop: "code",
            sortable: "custom",
          },
          {
            label: "标题",
            prop: "name",
            sortable: "custom",
          },
          {
            label: "设备分类",
            prop: "typeName",
            sortable: "custom",
          },
          {
            label: "适用范围",
            prop: "appName",
            sortable: "custom",
          },
          {
            label: "状态",
            prop: "status",
            sortable: "custom",
            formatter: (row) => {
              return row.status == 1 ? "已发布" : "草稿";
            },
          },
          {
            label: "创建单位",
            prop: "deptName",
            sortable: "custom",
          },
          {
            label: "创建人",
            prop: "createByName",
            sortable: "custom",
          },
          {
            label: "创建时间",
            prop: "createTime",
            sortable: "custom",
          },
        ],
        //表格方法
        tableMethods: {
          //点击行的方法
          rowClick: (row) => {
            this.$refs.klTable.radioSelect(row);
          },
        },
      },
    };
  },
  created() {
    this.tableSetting.searchObj.queryData = Object.assign(
      this.tableSetting.searchObj.queryData,
      this.searchData
    );
  },
  mounted() {
    // this.$refs.klTable.getTableConfig();
    this.currentAppid = this.$store.state.user.userInfo.appId;
    this.updateData();
  },
  methods: {
    updateData() {
      this.$refs.klTable.searchData();
    },
    // 获取表格数据
    getTableData(params, sortStr) {
      let queryData = Object.assign({}, params);
      if (sortStr.length > 0) {
        queryData.orders = sortStr;
      }
      queryData.appid = this.currentAppid;
      queryPatrolStandardList(queryData).then((res) => {
        this.$set(this.tableSetting, "tableData", res.data.records);
        this.$set(this.tableSetting, "totalNumber", res.data.total);
      });
    },
    //获取选中数据
    getSelectData() {
      let data = this.$refs.klTable.getRadioData();
      return data;
    },
  },
};
</script>
<style lang="less" scoped>
.constentmain {
  width: 100%;
  height: 100%;
  background-color: white;
  display: flex;
}
</style>